<?php

class Controller_Faqs extends Controller_TemplateNew
{
    public $_section;
    public $midle;
    
	public function  before() {
            parent::before();
            $this->db = Database::instance();
            $this->section = 'FAQs - ';

            $this->_section = 'faqs';

            $this->template->description = $this->settings['description'];
            $this->template->keywords = $this->settings['keywords'];
            $this->template->linkSettings = $this->settings;

            $this->template->header->active='faqs';
            $this->template->content = new View('faq/index');
            $this->template->content->downblock = new View('index/downblock');
            $this->template->content->downblock->formIdea = $this->formIdea;
            $this->midle = new View('index/midle');
            
            //down Block
            $allImages = $this->mod->getImagesByItem('index');
            $bottomBlock = $this->mod->getItem(95, 'index');
            $this->template->content->downblock->bottomBlock = $bottomBlock;
            if (isset($allImages[$bottomBlock['id']])) {
                foreach ($allImages[$bottomBlock['id']] as $key=>$value) {
                    $allImages[$bottomBlock['id']][$key]['imgPath'] = $this->mod->imagePath($value,'box4');
                }
            }
            $bottomBlockCategory = $this->mod->getCategoryByAlias('images-79','images');
            $formConfig = $this->mod->getItemByAlias('9','images');
            $this->template->content->downblock->showForm = ($formConfig['checkbox9']==1) ? true : false;
            $bottomBlockItems = $this->mod->getCategoryItems($bottomBlockCategory['id'],'images','position');
            $tempImg = $this->mod->getImagesByItem('images','position');
            $tempAtt = $this->mod->getAttachmentsByItem('images');
            foreach ($tempImg as $v) {
                $bottomBlockItems[$v[0]['itemId']]['box4'] = $this->mod->imagePath($v[0],'box4');
            }
            foreach ($tempAtt as $v) {
                $bottomBlockItems[$v[0]['itemId']]['attacment'] = $this->mod->attachmentPath($v[0]);
            }
            $this->template->content->downblock->items = $bottomBlockItems;
            if (isset($allImages)) {
                $this->template->content->downblock->allImages = $allImages;
            }
            //midle Block
            $midle = $this->mod->getItem(202, 'index');
            if (isset($allImages[$midle['id']])) {
                foreach ($allImages[$midle['id']] as $key=>$value) {
                    $temp[$key] = $this->mod->imagePath($value,'box5');
                }
            }
            $this->midle->images = $temp;
            //

            $signsList = $this->mod->getCategories('catalog', 'position');
            $this->template->content->signList = $signsList;
            $this->template->title = $this->section.$this->settings['title'];
                
	}
    
	public function actionIndex()
	{
                        
            $this->template->content->activeCategoryId = null;
            $this->template->content->question = $this->mod->getItemsByCategory('faq','position');
            $this->template->content->midleBlock = $this->midle;
	}
}